<<<<<<< HEAD
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Scrollpic extends MY_Controller {
		
	function __construct(){
		parent::__construct();
		/** 登陆验证 */
		if(!isset($_SESSION)){
		    session_start();
		}
		$admin = $this->session->userdata('admin_user');
		if(!$admin || !isset($admin['user_id'])){
			header('Location: /sys_admin/login');
			exit;
		}
		$this->tab = 'platform';
		$this->sub = 'ad';
		
	}
	
	function add_view(){
		$this->load->helper(array('form'));
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = $this->sub;
		
		$this->load->view("/sys_admin/site/scrollpic_add",$vdata);
	}
	
	private function post_data(){
		$data = array(
				'url'=>$this->input->post('url'),
				'title'=>$this->input->post('title'),
				'forder'=>$this->input->post('forder'),
			);
		if($data['url'] == ''){
			$ret['msg'] = '图片链接不能为空';
		}elseif($data['title'] == ''){
			$ret['msg'] = '图片说明不能为空';
		}
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
		$thumbnail = "";
		if(isset($_FILES['thumbnail']) && $_FILES['thumbnail']['name'] != ''){
			$thumbnail = $this->upload_thumbnail(UPFILES_SCROLLPIC_IMG, SCROLLPIC_IMG_PATH,'scrollpic_');
		}
  		$data['pic'] 	= $thumbnail;
  		return $data;
	}
	
	function add(){
						
		$data = $this->post_data();
		
  		$data['add_time'] 	= time();
  		$data['addip'] 		= $this->js->get_ip();
  		
  		$this->load->model('scrollpic_model');
  		$scrollpic_id = $this->scrollpic_model->add($data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[添加广告条]['.$this->input->post('url').']');
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	function view($scrollpic_id){
		$this->load->model('scrollpic_model');
  		$scrollpic = $this->scrollpic_model->get_scrollpic_obj($scrollpic_id);
  		$vdata['scrollpic'] = $scrollpic;
  		
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = $this->sub;
		
  		$this->load->view("/sys_admin/site/scrollpic_view", $vdata);
	}
	
	function edit_view($scrollpic_id){
		$this->load->helper(array('form'));
		$this->load->model('scrollpic_model');
  		$scrollpic = $this->scrollpic_model->get_scrollpic_obj($scrollpic_id);
  		$vdata['scrollpic'] = $scrollpic;
  		
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = $this->sub;
		
  		$this->load->view("/sys_admin/site/scrollpic_edit", $vdata);
	}
	
	function edit(){
		$id 		= $this->input->post('id');
		
		$bpic 		= $this->input->post('bpic');
		
		$data = $this->post_data();
  		$data['pic'] 		= $data['pic']?$data['pic']:$bpic;
  		
  		$this->load->model('scrollpic_model');
  		$scrollpic_id = $this->scrollpic_model->update($id, $data);

  		
  		$this->load->model('log_model');
  		$this->log_model->add_log('[编辑广告条]'.'ID=='.$id);
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	function zhs_scrollpiclist(){
		$this->load->model('scrollpic_model');
		$vdata = $this->scrollpic_model->get_scrollpic_list();
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = $this->sub;
		
		$this->load->view('/sys_admin/site/scrollpic_list', $vdata);
	}
	
	function remove(){
		$id 				= $this->input->post('id');
  		$data["is_del"]		= 1;
  		$this->load->model('scrollpic_model');
		echo  $this->scrollpic_model->update($id, $data);
		$this->load->model('log_model');$this->log_model->add_log('[删除][滚动图片]');
	}
	
}
=======
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Scrollpic extends MY_Controller {
    	
	function __construct(){
		parent::__construct();
		/** 登陆验证 */
		if(!isset($_SESSION)){
		    session_start();
		}
		$admin = $this->session->userdata('admin_user');
		if(!$admin || !isset($admin['user_id'])){
			header('Location: /sys_admin/login');
			exit;
		}
		$this->tab = 'platform';
		$this->sub = 'ad';
		
	}
	
	function add_view(){
		$this->load->helper(array('form'));
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = $this->sub;
		
		$this->load->view("/sys_admin/site/scrollpic_add",$vdata);
	}
	
	private function post_data(){
		$data = array(
				'url'=>$this->input->post('url'),
				'title'=>$this->input->post('title'),
				'forder'=>$this->input->post('forder'),
			);
		if($data['url'] == ''){
			$ret['msg'] = '图片链接不能为空';
		}elseif($data['title'] == ''){
			$ret['msg'] = '图片说明不能为空';
		}
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
		$thumbnail = "";
		if(isset($_FILES['thumbnail']) && $_FILES['thumbnail']['name'] != ''){
			$thumbnail = $this->upload_thumbnail(UPFILES_SCROLLPIC_IMG, SCROLLPIC_IMG_PATH,'scrollpic_');
		}
  		$data['pic'] 	= $thumbnail;
  		return $data;
	}
	
	function add(){
						
		$data = $this->post_data();
		
  		$data['add_time'] 	= time();
  		$data['addip'] 		= $this->js->get_ip();
  		
  		$this->load->model('scrollpic_model');
  		$scrollpic_id = $this->scrollpic_model->add($data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[添加广告条]['.$this->input->post('url').']');
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	function view($scrollpic_id){
		$this->load->model('scrollpic_model');
  		$scrollpic = $this->scrollpic_model->get_scrollpic_obj($scrollpic_id);
  		$vdata['scrollpic'] = $scrollpic;
  		
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = $this->sub;
		
  		$this->load->view("/sys_admin/site/scrollpic_view", $vdata);
	}
	
	function edit_view($scrollpic_id){
		$this->load->helper(array('form'));
		$this->load->model('scrollpic_model');
  		$scrollpic = $this->scrollpic_model->get_scrollpic_obj($scrollpic_id);
  		$vdata['scrollpic'] = $scrollpic;
  		
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = $this->sub;
		
  		$this->load->view("/sys_admin/site/scrollpic_edit", $vdata);
	}
	
	function edit(){
		$id 		= $this->input->post('id');
		
		$bpic 		= $this->input->post('bpic');
		
		$data = $this->post_data();
  		$data['pic'] 		= $data['pic']?$data['pic']:$bpic;
  		
  		$this->load->model('scrollpic_model');
  		$scrollpic_id = $this->scrollpic_model->update($id, $data);

  		
  		$this->load->model('log_model');
  		$this->log_model->add_log('[编辑广告条]'.'ID=='.$id);
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	function zhs_scrollpiclist(){
		$this->load->model('scrollpic_model');
		$vdata = $this->scrollpic_model->get_scrollpic_list();
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = $this->sub;
		
		$this->load->view('/sys_admin/site/scrollpic_list', $vdata);
	}
	
	function remove(){
		$id 				= $this->input->post('id');
  		$data["is_del"]		= 1;
  		$this->load->model('scrollpic_model');
		echo  $this->scrollpic_model->update($id, $data);
		$this->load->model('log_model');$this->log_model->add_log('[删除][滚动图片]');
	}
	
}
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
